﻿using UnityEngine;
using System.Collections;
using UI;
using ProtoBuf.Message;


public class ContinueRechargeIcon : CommonIcon
{

    public int index = 0;
    public ActivityItem curItem = null;
    public UILabel dayCount;

    public UIActivityContinueChargeGift ContinueChargeGift;
    public int pickOneOrGetAll;

    public GameObject redPoint;


    /// <summary>
    /// 设置icon数据
    /// </summary>
    public void SetButtomData(ActivityItem item, bool Specular)
    {
        base.SetData("item_icon_070", true, -1);
        curItem = item;
        frame.gameObject.SetActive(false);
        index = item.index;
        pickOneOrGetAll = item.pickOneOrGetAll;
        if (Specular)
        {
            frame.gameObject.SetActive(true);
            frame.spriteName = "UI_kaung_xuanzhong_01";
        }

        switch (item.index)
        {
            case 1:
            case 2:
            case 3:
                itemIcon.textureName = "item_icon_070";
                break;
            case 4:
            case 5:
            case 6:
                itemIcon.textureName = "item_icon_071";
                break;
            default:
                itemIcon.textureName = "item_icon_072";
                break;
        }
        dayCount.text = item.index.ToString();
        redPoint.SetActive(item.status==1);
    }

    public override void OnClick()
    {
        if (clickDesc)
        {
            string morePickOneItem = "";
            foreach (var item in curItem.rewardList)
            {
                string itemParam = item.id + "," + item.num.ToString();
                morePickOneItem += itemParam + ";";
            }
            if (curItem.status == (int)UIActivityContinueChargeGift.GiftState.Receive)
            {
                if (curItem.pickOneOrGetAll == (int)UIActivityContinueChargeGift.PickOne.No)
                {
                    ContinueChargeGift.ShowGetGiftPanel(curItem);
                }
                else if (curItem.pickOneOrGetAll == (int)UIActivityContinueChargeGift.PickOne.Sure)
                {
                    ContinueChargeGift.ShowSelectGiftPanel(curItem);
                }
            }
            else
            {
                //PageManager.instance.OpenPage("ShopGiftPreview", "activityGetGiftId=" + morePickOneItem + "&type=3");
                ContinueChargeGift.ShowShowCCGiftPanel(curItem);
            }
        }
    }
}
